package com.robusta.cityuate.services;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

abstract public class CityuateBroadCastReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context ctx, Intent intent) {
		boolean cancel = intent.getExtras().getBoolean(HTTPService.CANCEL,
				false);
		if (cancel) {
			onCancel();
			return;
		}

		boolean result = intent.getExtras().getBoolean(HTTPService.RESUlT);
		Log.d("onRecieve", result + "");
		if (result)
			onSuccess();
		else
			onFailure();

	}

	/**
	 * when canceling a connection
	 */
	abstract public void onCancel();

	/**
	 * add success scenario when receiving
	 */
	abstract public void onSuccess();

	/**
	 * add failure scenario when receiving
	 */
	abstract public void onFailure();

}
